﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using System.Collections;


public class email
{
    
    public string to { get; set; }  
    public string from { get; set; }
    public string subject { get; set; }
    public string message { get; set; }

    public email()
	{
        to = string.Empty;
        from = string.Empty;
        subject = string.Empty;
        message = string.Empty;
	}


   
    public email(string To, string From, string Subject, string Message)
    {
        to = To;
        from = From;
        subject = Subject;
        message = Message;
    }

 
    public void init(string To, string From, string Subject, string Message)
    {
        to = To;
        from = From;
        subject = Subject;
        message = Message;
    } 

   
    public bool sendMail()
    {
        bool ok = true;

        MailAddress f = new MailAddress(from);

        MailAddress t = new MailAddress(to);

        MailMessage m = new MailMessage(f, t);

        m.Subject = subject;
        m.Body = message;

        SmtpClient client = new SmtpClient("smtp1.centennialcollege.ca");

        try
        {
            client.Send(m);
        }
        catch (Exception ex)
        {
            ok = false;
        }
        return ok;

    }

    }
    
    
    

